package com.bokee.archerwq.lab.thread;

public class SleepingThread extends Thread {

	private int id;

	public SleepingThread(int id) {
		this.id = id;
		start();
	}

	@Override
	public String toString() {
		return "Thread" + id;
	}

	@Override
	public void run() {
		for (int countDown = 5; countDown > 0; countDown--) {
			System.out.println(this + "->" + countDown);
			try {
				Thread.sleep(100);
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		for (int i = 0; i < 5; i++) {
			try {
				new SleepingThread(i + 1).join();
			} catch (Exception e) {
				throw new RuntimeException(e);
			}

		}
	}

}
